#include "Car.h"
#include <iostream>
#include <string>
#include <ctime>
using namespace std;

Car::Car(void)
{
}
Car::~Car(void)
{
}
int main(){
	srand ( time(NULL) );
	int ryear;
	int rgastank;
	int rgaslev;
	int rmile;
	int rmpg;
	rgastank= (rand() % 35 + 15);
	rgaslev= (rand() % rgastank + 10);
	ryear= 1979 + (rand() % 32 + 1);
	rmpg= 15 + (rand() % 15 + 1);
	rmile= 40000 + (rand() % 200000 +1);
	Car truck= Car("Truck", ryear, rgaslev, rgastank, rmpg, rmile);
	bool again;
	again=true;
	bool choice;
	choice=true;
	int enter;
	double distance;
	do{
		system("cls");
		cout<<"Your Car:\n"<<endl;
		cout<<"Make: ";
		cout<<truck.getMake()<<endl;
		cout<<"Year: ";
		cout<<truck.getYear()<<endl;
		cout<<"Gas Level: ";
		cout<<truck.getGaslev();
		cout<<" gallon(s)"<<endl;
		cout<<"Gas Capacity: "; 
		cout<<truck.getGascap();
		cout<<" gallon(s)"<<endl;
		cout<<"Miles traveled: ";
		cout<<truck.getMiles()<<endl;
		cout<<"Miles per Gallon: ";
		cout<<truck.getMpg()<<endl;
		cout<<"\n";
		system("pause");
		system("cls");
		do {
			cout<<"Would you like to drive? (1 for Yes, 0 for No)"<<endl;
			cin>>enter;
			system("cls");
			if (enter==1){
				cout<<"How far would you like to move?"<<endl;
				cin>>distance;
				if (truck.getGaslev()-(distance/truck.getMpg())<0 || (distance<0)){
					cout<<"You don't have enough gas!"<<endl;
					choice=true;
					again=true;
					system("pause");
					system("cls");
				}
				else{
					truck.carMove(distance);
					choice=false;
					again=true;
				}
			}
			if (enter==0){
				choice=false;
				again=false;
				cout<<"Goodbye!"<<endl;
				system("pause");
			}
			if (enter!=0 && enter!=1){
				cout<<"That is not a valid response!"<<endl;
				system("pause");
				system("cls");
				choice=true;
				again=false;
			}
		}while(choice==true);
	}while (again==true);
	return 0;
}